<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon" href="../../favicon.ico">
  <title>农场后台人员系统</title>
  <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="/bower_components/bootstrap/docs/examples/signin/signin.css">
  <style type="text/css">
    body{
      background-image: url("/bower_components/image/3.jpg");
      background-size: 100%;
    }
    .ndTitle{
      text-align: center;
    }
    .bugP{
      color: red;
      text-align: center;
    }
    #loginA{
      float: right;
      padding-right: 3px;
    }
  </style>

</head>

<body>

<div class="container">

  <form class="form-signin">
    <h2 class="form-signin-heading ndTitle">农场人员后台系统</h2>
    <p class="bugP"></p>
    <label for="inputUsername" class="sr-only">用户名</label>
    <input type="text" id="inputUsername" class="form-control" placeholder="请输入用户名" required autofocus>
    <label for="inputPassword" class="sr-only">密码</label>
    <input type="password" id="inputPassword" class="form-control" placeholder="请输入密码" required>


    <div class="form-group">
      <label class="col-md-2 control-label">验证码</label>
      <div class="col-md-10">
        <input type="text" name="verify" id="verify" required>
        <canvas width="100" height="40" id="verifyCanvas"></canvas>
        <img id="code_img">
      </div>
    </div>



    <div class="checkbox">
      <label>
        <input type="checkbox" value="remember-me"> 记住我
      </label>
      <a id="loginA" href="/registerUI">去注册</a>
    </div>
    <button id="loginId" class="btn btn-lg btn-primary btn-block" type="button">登录</button>
  </form>

</div> <!-- /container -->

<!-- jQuery 3 -->
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

<script type="text/javascript">
  //验证码
  // var yzhm = '' ;
  // yzhm = drawCode("verifyCanvas" , 4);
  // // 点击图片换验证码
  // $("#code_img").click(function(){
  //   changeYzhm();
  // });

  $(function () {
    $("#loginId").click(doLogin);
  });
  function doLogin() {
    var url="/user/doLogin";
    var param={
      username:$("#inputUsername").val(),
      password:$("#inputPassword").val()
    }
    console.log(param);


    $.post(url,param,function (result) {
      if (result.message=="NO"){
        $(".bugP").html("您输入的用户名或密码错误");
      }else{
        location.href="/starterUI?t="+Math.random();
      }
    });


    // $(".bugP").html("您输入的用户名或密码错误");
  }

</script>

</body>
</html>
